#!/usr/bin/make -f
# -*- makefile -*-
# Makefile for nanoflann Debian package.

# Uncomment this to turn on verbose mode.
export DH_DEBUG=1
export DH_VERBOSE=1


# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

config.status: configure
	dh_testdir
	# Add here commands to configure the package.
	./configure NANOFLANN_IS_DEB_PACKAGE=1 --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"

build: build-arch build-indep

build-arch: build-stamp
build-indep: build-stamp

build-stamp:  config.status
	dh_testdir

	touch $@

distclean:
    # Nothing to do (do not remove this line!)

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp 

	# Add here commands to clean up after the build process.
	rm -f config.sub config.guess

	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs

	# Add here commands to install the package into debian/...
	./configure NANOFLANN_IS_DEB_PACKAGE=1 --prefix=$(CURDIR)/debian/ CMAKE_MRPT_USE_DEB_POSTFIXS="1"

	# Build all
	$(MAKE) VERBOSE=1
	# Run tests
	make test

	# Install
	$(MAKE) install
	
# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
	# Register .desktop files with a MIME type:
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb


# Build architecture-dependent files here.
binary-arch:
	# Nothing to do

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install 

